#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        string s1 = strs[0];
        if (s1 == "")
        {
            return s1;
        }

        size_t max = s1.size();
        for (int i = 1; i < strs.size(); ++i)
        {
            int j = 0;
            for (j = 0; j < strs[i].size() && j < s1.size(); ++j)
            {
                if (strs[i][j] != s1[j])
                {
                    break;
                }
            }
            max = j < max ? j : max;
        }

        string s2(s1.begin(), s1.begin() + max);

        return s2;
    }
};